package com.tanwu.ccs.entity.common;

/**
 * 分页类
 * @author TanWu
 */
public class Page {
	private int totalRows; 		// 总行数
	private int pageSize; 		// 每页显示的行数
	private int currentPage; 	// 当前页号
	private int totalPages; 	// 总页数
	private int startRow; 		// 当前页在数据库中的起始行
	private String linkUrl; 	// 要跳转的URL
	
	public Page() {
	}
	
	/**
	 * 分页方法
	 * @param _totalRows
	 * @param _pageSize
	 */
	public Page(int _totalRows,int _pageSize){
		this.totalRows = _totalRows;
		this.pageSize = _pageSize;
		this.totalPages = totalRows/pageSize;
		int mod = totalRows%pageSize;
		if(mod > 0){
			totalPages++;
		}
		this.currentPage = 1;
		this.startRow = 0;
	}
	
	/**
	 * 设定hibernate查询的起始行数
	 * @param _currentPage
	 */
	public void setStartPage(int _currentPage){
		this.currentPage = _currentPage;
		this.startRow = (currentPage-1)*pageSize;
	}
	
	public int getTotalRows() {
		return totalRows;
	}
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
	public int getStartRow() {
		return startRow;
	}
	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}
	public String getLinkUrl() {
		return linkUrl;
	}
	public void setLinkUrl(String linkUrl) {
		this.linkUrl = linkUrl;
	}
}
